package nl.tudelft.jpacman.npc.ghost;

import nl.tudelft.jpacman.board.BoardFactory;
import nl.tudelft.jpacman.board.Direction;
import nl.tudelft.jpacman.board.Square;
import nl.tudelft.jpacman.level.LevelFactory;
import nl.tudelft.jpacman.level.MapParser;
import nl.tudelft.jpacman.npc.Ghost;
import nl.tudelft.jpacman.points.DefaultPointCalculator;
import nl.tudelft.jpacman.sprite.Sprite;

import java.util.List;
import java.util.Map;

public final class GhostMapParser extends MapParser {
    private final LevelFactory levelFactory;
    private final BoardFactory boardFactory;
    private GhostFactory ghostFactory = null;

    // 两参数构造函数（调用父类两参数构造函数）
    public GhostMapParser(LevelFactory levelFactory, BoardFactory boardFactory) {
        super(levelFactory, boardFactory);
        this.levelFactory = levelFactory;
        this.boardFactory = boardFactory;
    }

    // 六参数构造函数（调用父类六参数构造函数）
    public GhostMapParser(
        LevelFactory lf1,
        BoardFactory bf1,
        DefaultPointCalculator pointCalculator,
        Map<Direction, Sprite> directionSprites,
        LevelFactory lf2,
        BoardFactory bf2
    ) {
        super(lf1, bf1, pointCalculator, directionSprites, lf2, bf2);
        this.levelFactory = lf2;
        this.boardFactory = bf2;
    }


    @Override
    protected void addSquare(Square[][] grid, List<Ghost> ghosts,
                             List<Square> startPositions, int x, int y, char c) {
        switch (c) {
            case 'C':
                grid[x][y] = makeGhostSquare(ghosts, ghostFactory.createClyde());
                break;
            default:
                super.addSquare(grid, ghosts, startPositions, x, y, c);
        }
    }
}
